package domain.game;

import com.uqbar.vainilla.DeltaState;

public class TransitionState extends GameState {

	private double secondsUntilChange;
	private GameState nextState;
	private double currentSeconds;
	
	public TransitionState(KeysHandler kh, GameState nextState, double seconds) {
		super(kh);
		this.secondsUntilChange = seconds;
		this.currentSeconds = 0;
		this.nextState = nextState;
	}

	
	public void update(DeltaState delta){
		currentSeconds += delta.getDelta();

		if (this.currentSeconds >= this.secondsUntilChange){
			nextState.setKeysHandler(this.getKeysHandler());
			this.newState(nextState);
		}
	}
}
